package cn.wx.api;

import me.chanjar.weixin.mp.api.WxMpService;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * WxMpService代理
 *
 * @author: sunshaoping
 * @date: Create by in 4:35 下午 2020/5/23
 */
public class WxMpServiceProxy implements InvocationHandler {

    private final String name;

    private final WxMpService wxMpService;

    public WxMpServiceProxy(String name, WxMpService wxMpService) {
        this.name = name;
        this.wxMpService = wxMpService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        return method.invoke(wxMpService.switchoverTo(name), args);
    }
}
